﻿using System.Text;

namespace RWLib
{
    public class ActionModel
    {
        private ActionTypeEnum _type;
        private string _req, _eff, _action;
        private int _time;
        public string Name;

        public ActionModel(string name, string req, string eff, string action, int time, ActionTypeEnum type)
        {
            _req = req;
            _eff = eff;
            _action = action;
            _time = time;
            _type = type;
            Name = name;
        }

        public string ToString()
        {
            //"Load_R causes loadedR if not loadedR"
            //"[(not alive or loadedR) and not alive and loadedL and (hidden or sung) and (hidden or not shot)]");
            //"Load_L causes loadedL"
            //"Shoot_Fred_right causes not alive if not hidden and loadedR"
            //"Shoot_Fred_left releases alive if (alive and (not hidden or loadedL))"
            //"Sing causes hidden if not hidden"
            //"hidden triggers Wait"
            //"impossible Shoot_Fred_RIGHT at 4"
            //"Wait invokes Unhide after 3"
            //"Unhide causes not hidden if hidden";
            var sb = new StringBuilder();
            switch (_type)
            {
                case ActionTypeEnum.Causes:
                    sb.Append(Name + " causes " + _eff);
                    if (string.IsNullOrEmpty(_req)) break;
                    sb.Append(" if " + _req);
                    break;
                case ActionTypeEnum.Releases:
                    sb.Append(Name + " releases " + _eff);
                    if (string.IsNullOrEmpty(_req)) break;
                    sb.Append(" if " + _req);
                    break;
                case ActionTypeEnum.Invokes:
                    sb.Append(Name + " invokes " + _action + " after " + _time);
                    break;
                case ActionTypeEnum.Trigger:
                    sb.Append(_req + " triggers " + _action);
                    break;
                case ActionTypeEnum.Impossible:
                    sb.Append("impossible " + _action + " if " + _req);
                    break;
                case ActionTypeEnum.ImpossibleAtTime:
                    sb.Append("impossible " + _action + " at " + _time);
                    break;
            }
            return sb.ToString();
        }
    }
}
